import request from '@/utils/request'

// 教师相关API接口
const TeacherAPI = {
  // 示例方法
  getCourseList() {
    return request({
      url: '/teacher/courses',
      method: 'get'
    })
  },

  // 查看学生考试成绩
  getStudentGrades() {
    return request({
      url: '/teacher/viewStudentGrades',
      method: 'get'
    })
  },

  // 创建科目
  createSubject(subjectData) {
    return request({
      url: '/teacher/createSubject',
      method: 'post',
      data: subjectData
    })
  },

  // 获取科目列表
  getSubjectList(pageNum = 1, pageSize = 10) {
    return request({
      url: '/teacher/subjects',
      method: 'get',
      params: {
        pageNum,
        pageSize
      }
    })
  },

  // 手动导入题目
  importQuestionsManual(questionData) {
    return request({
      url: '/teacher/importQuestionsManual',
      method: 'post',
      data: questionData
    })
  },

  // Excel导入题目
  importQuestionsExcel(file, subjectId) {
    const formData = new FormData()
    formData.append('file', file)
    formData.append('subjectId', subjectId)
    
    return request({
      url: '/teacher/importQuestionsExcel',
      method: 'post',
      data: formData,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  },

  // AI生成题目
  importQuestionsAI(subjectId, count) {
    return request({
      url: '/teacher/importQuestionsAI',
      method: 'post',
      params: {
        subjectId,
        count
      },
      timeout: 300000 // 5分钟超时时间
    })
  }
}

export default TeacherAPI